package com.bolt.support.sqlconfig.base;

import com.bolt.common.convert.Converter;
import com.bolt.common.convert.ConverterRegistry;

import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;


public class SQLConfiguration {
    protected final Map<String, SqlStatement> statements = new HashMap<String, SqlStatement>();

    private final ConverterRegistry typeConverterRegistry = new ConverterRegistry();

    public void addStatements(SqlStatement sm) {
        statements.put(sm.getId(), sm);
    }

    public Collection<String> getStatementNames() {
        return statements.keySet();
    }

    public Collection<SqlStatement> getMappedStatements() {
        return statements.values();
    }

    public SqlStatement getMappedStatement(String id) {
        return statements.get(id);
    }

    public void clean() {
        statements.clear();
    }

    public ConverterRegistry getTypeConverterRegistry() {
        return typeConverterRegistry;
    }

    public void putCustomConverter(Type type, Class<? extends Converter<?>> converterClass) {
        this.getTypeConverterRegistry().putCustom(type, converterClass);
    }


}
